package it.xiuxian.personcenter.presenter

import com.lzy.okgo.OkGo
import it.xiuxian.lib.base.BaseBean
import it.xiuxian.lib.base.BasePresenter
import it.xiuxian.lib.base.ILoadBind
import it.xiuxian.lib.http.CallBackOption
import it.xiuxian.lib.http.HttpConfig
import it.xiuxian.lib.utils.EncodeUtils
import it.xiuxian.lib.utils.ToastUtil
import it.xiuxian.personcenter.activity.MyWalletActivity
import it.xiuxian.personcenter.bean.DetailListBean
import it.xiuxian.personcenter.bean.WalletDetailBean
import org.json.JSONObject

class MyWalletActivityPresenter:BasePresenter<MyWalletActivity>() {
    fun getRecord(){
        OkGo.post<BaseBean<WalletDetailBean>>(HttpConfig.BASE_URL+"/appuser/getMoney")
            .execute(object : CallBackOption<BaseBean<WalletDetailBean>>() {}.loadBind(mView as MyWalletActivity).execute(
                object : ILoadBind<BaseBean<WalletDetailBean>> {
                    override fun excute(bean: BaseBean<WalletDetailBean>) {
                        if(bean.code==0){
                            (mView as MyWalletActivity).setGongXian(bean.data)
                        }
                    }
                }
            ))
    }
    fun getDetail(pageNo:String,leixing:String){
        var json1 = JSONObject()
        json1.put("pageNo",pageNo)
            .put("leixing",leixing)
        OkGo.post<BaseBean<DetailListBean>>(HttpConfig.BASE_URL+"/appmingxi/list")
            .params("encrypt", EncodeUtils.encodeAES(json1.toString()))
            .execute(object : CallBackOption<BaseBean<DetailListBean>>() {}.loadBind(mView as MyWalletActivity).execute(
                object : ILoadBind<BaseBean<DetailListBean>> {
                    override fun excute(bean: BaseBean<DetailListBean>) {
                        if(bean.code==0){
                            (mView as MyWalletActivity).setData(bean.data)

                        }
                    }
                }
            ))
    }

}